import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
testcase = "DBshop006_订单删除管理订单"
# 1.点击销售管理订单管理界面。
ff = openBrowser(urlAdmin)
DBshopLoginAdmin(ff)
DBshopEnterMenu2(ff, "销售管理", "订单管理")
# 2.在订单状态点击已取消一栏，点击“搜索”按钮一款，勾选之后，选择删除，点击提交操作。
ff.find_element_by_xpath('//option[@value="0"]').click()
ff.find_element_by_xpath('//button').click()
ff.find_element_by_id("select_checkbox_state_1").click()
ff.find_element_by_xpath('//option[@value="del"]').click()
ff.find_element_by_xpath('//button[@onclick="return editAllOrders();"]').click()
ff.switch_to.alert.accept()
time.sleep(1)
# 3.删除成功(删除成功已取消的客户信息)
s = ff.find_element_by_xpath("//body").text
l = "订单数\："
r = "\)"
num1 = reGetString(s, l, r)
print(num1)
if int(num1) == 0:
    writeLog("%s 测试通过" % (testcase))
else:
    writeLog("%s 测试失败" % (testcase))
    getPhoto(ff)
ff.quit()